<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="album" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{albumHome.managed ? 'Edit' : 'Add'} Album</f:facet>





            <s:decorate id="createdField" template="layout/edit.xhtml">
                <ui:define name="label">Created</ui:define>
                <rich:calendar id="created"
                       required="true"
                          value="#{albumHome.instance.created}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="descriptionField" template="layout/edit.xhtml">
                <ui:define name="label">Description</ui:define>
                <h:inputTextarea id="description"
                               cols="80"
                               rows="10"
                              value="#{albumHome.instance.description}"/>
            </s:decorate>


            <s:decorate id="lastupdatedField" template="layout/edit.xhtml">
                <ui:define name="label">Lastupdated</ui:define>
                <rich:calendar id="lastupdated"
                       required="true"
                          value="#{albumHome.instance.lastupdated}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>



            <s:decorate id="publishedField" template="layout/edit.xhtml">
                <ui:define name="label">Published</ui:define>
                <h:selectBooleanCheckbox id="published"
                                   required="true"
                                      value="#{albumHome.instance.published}"/>
            </s:decorate>



            <s:decorate id="titleField" template="layout/edit.xhtml">
                <ui:define name="label">Title</ui:define>
                <h:inputTextarea id="title"
                               cols="80"
                               rows="3"
                           required="true"
                              value="#{albumHome.instance.title}"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{albumHome.persist}"
                       disabled="#{!albumHome.wired}"
                       rendered="#{!albumHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{albumHome.update}"
                       rendered="#{albumHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{albumHome.remove}"
                      immediate="true"
                       rendered="#{albumHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Album.xhtml"
                rendered="#{albumHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty albumFrom ? 'AlbumList' : albumFrom}.xhtml"
                rendered="#{!albumHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Access *" labelClass="required">
    <div class="association" id="accessParent">

        <h:outputText value="There is no access associated with this album."
                   rendered="#{albumHome.instance.access == null}"/>

        <rich:dataTable var="_access"
                   value="#{albumHome.instance.access}"
                rendered="#{albumHome.instance.access != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="accessTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_access.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Access</f:facet>
                <h:outputText value="#{_access.access}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Description</f:facet>
                <h:outputText value="#{_access.description}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{albumHome.instance.access != null ? 'changeParent' : 'selectParent'}" value="#{albumHome.instance.access != null ? 'Change' : 'Select'} access"
                       view="/AccessList.xhtml">
                <f:param name="from" value="AlbumEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Category">
    <div class="association" id="categoryParent">

        <h:outputText value="There is no category associated with this album."
                   rendered="#{albumHome.instance.category == null}"/>

        <rich:dataTable var="_category"
                   value="#{albumHome.instance.category}"
                rendered="#{albumHome.instance.category != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="categoryTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_category.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Label</f:facet>
                <h:outputText value="#{_category.label}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Parent id</f:facet>
                <h:outputText value="#{_category.parent.id}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{albumHome.instance.category != null ? 'changeParent' : 'selectParent'}" value="#{albumHome.instance.category != null ? 'Change' : 'Select'} category"
                       view="/CategoryList.xhtml">
                <f:param name="from" value="AlbumEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Owner *" labelClass="required">
    <div class="association" id="ownerParent">

        <h:outputText value="There is no owner associated with this album."
                   rendered="#{albumHome.instance.owner == null}"/>

        <rich:dataTable var="_user"
                   value="#{albumHome.instance.owner}"
                rendered="#{albumHome.instance.owner != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="ownerTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_user.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Dsc</f:facet>
                <h:outputText value="#{_user.dsc}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Email</f:facet>
                <h:outputText value="#{_user.email}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Firstname</f:facet>
                <h:outputText value="#{_user.firstname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Lastloggedin</f:facet>
                <h:outputText value="#{_user.lastloggedin}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Lastname</f:facet>
                <h:outputText value="#{_user.lastname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Password</f:facet>
                <h:outputText value="#{_user.password}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Registered</f:facet>
                <h:outputText value="#{_user.registered}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Role id</f:facet>
                <h:outputText value="#{_user.role.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status id</f:facet>
                <h:outputText value="#{_user.status.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Username</f:facet>
                <h:outputText value="#{_user.username}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{albumHome.instance.owner != null ? 'changeParent' : 'selectParent'}" value="#{albumHome.instance.owner != null ? 'Change' : 'Select'} owner"
                       view="/UserList.xhtml">
                <f:param name="from" value="AlbumEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
